//
//  HYCTourPalCell.m
//  FamilyTravel
//
//  Created by dllo on 15/10/29.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "HYCTourPalCell.h"
#import "HYCHeadDocument.h"
#define WIDTH self.contentView.frame.size.width
#define HEIFGT self.contentView.frame.size.height
@implementation HYCTourPalCell
- (void)dealloc {
    [_tuIamgeView release];
    [_scrLabel release];
    [_timeLabel release];
    [_addLabel release];
    [_likeLabel release];
    [_moneyLabel release];
    [_autImageView release];
    
    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}
- (void)createCell{
    self.tuIamgeView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.tuIamgeView];
//    self.tuIamgeView.backgroundColor = [UIColor redColor];
    [_tuIamgeView release];
    
    self.scrLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.scrLabel];
    [_scrLabel release];
    self.scrLabel.numberOfLines = 0;
    self.scrLabel.font = [UIFont systemFontOfSize:12];
//    self.scrLabel.backgroundColor = [UIColor yellowColor];
    
    self.timeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.timeLabel];
//    self.timeLabel.backgroundColor = [UIColor blackColor];
    [_timeLabel release];
    self.timeLabel.font = [UIFont systemFontOfSize:12];
    
    self.addLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.addLabel];
    [_addLabel release];
//    self.addLabel.backgroundColor = [UIColor redColor];
    self.addLabel.font = [UIFont systemFontOfSize:12];
    
    self.likeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.likeLabel];
    [_likeLabel release];
    self.likeLabel.font = [UIFont systemFontOfSize:12];
//    self.likeLabel.backgroundColor = [UIColor blackColor];
    
    self.moneyLabel = [[UILabel alloc] init];
    [self.contentView addSubview: self.moneyLabel];
    [_moneyLabel release];
    self.moneyLabel.font = [UIFont systemFontOfSize:12];
//    self.moneyLabel.backgroundColor = [UIColor yellowColor];
    
    self.autImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.autImageView];
//    self.autImageView.layer.borderWidth  = 0.5;
    self.autImageView.layer.cornerRadius = WIDTH / 12;
    self.autImageView.layer.masksToBounds = YES;
    [_autImageView release];
//    self.autImageView.backgroundColor = [UIColor grayColor];

}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.tuIamgeView.frame = CGRectMake(WIDTH / (WIDTH / 5), 5, WIDTH - 10, HEIFGT / 3 * 2 - 10);
    self.scrLabel.frame = CGRectMake(WIDTH / (WIDTH / 15), HEIFGT / 3 * 2, WIDTH / 3 * 2, WIDTH / 6);
    
    self.timeLabel.frame = CGRectMake(WIDTH / (WIDTH / 15), HEIFGT / 8 * 7, WIDTH / 4, WIDTH / 17);
    self.addLabel.frame = CGRectMake(WIDTH / 3 + 10, HEIFGT / 8 * 7, WIDTH / 3, WIDTH / 17);
    
    self.likeLabel.frame = CGRectMake(WIDTH / 4 * 3 , HEIFGT / 5 * 4, WIDTH / 4 - 5, WIDTH / 11);
    self.moneyLabel.frame = CGRectMake(WIDTH / 4 * 3, HEIFGT / 10 * 9, WIDTH / 4 - 5, 20);
    self.autImageView.frame = CGRectMake(WIDTH / 4 * 3 + 5, HEIFGT / 2, WIDTH / 6, WIDTH / 6);
    
}

- (void)setModel:(HYCTourPalModel *)model {
    if (self.model != model) {
        [_model release];
        _model = [model retain];
    
        [self.tuIamgeView sd_setImageWithURL:[NSURL URLWithString:_model.cover]placeholderImage:[UIImage imageNamed:@"zw.png"]];
        self.timeLabel.text = _model.start_date;
//        self.addLabel.text = _model.;
        
        self.scrLabel.text = _model.name;
        
        NSString *mStr = [NSString stringWithFormat:@"%@%@", _model.total_days, @"天"];
//
        self.moneyLabel.text = mStr;
        
        
        NSString *str = [NSString stringWithFormat:@"%@%@", _model.photo_number, @"图"];
        self.likeLabel.text = str;
        
    }
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
